package com.example.dql.diary.PictureSelection;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.Priority;
import com.bumptech.glide.request.RequestOptions;
import com.zhihu.matisse.engine.ImageEngine;

/**
 * Created by dql on 2018/4/3.
 */

public class MyGlideEngine implements ImageEngine {
	@Override
	public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {
		RequestOptions options = new RequestOptions()
				.centerCrop()
				.override(resize, resize);
		Glide.with(context)
				.asBitmap()
				.load(uri)
				.apply(options)
				.into(imageView);
	}

	@Override
	public void loadAnimatedGifThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView,
										 Uri uri) {
		Glide.with(context)
				.asBitmap()
				.load(uri)
				.into(imageView);
	}

	@Override
	public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
		Glide.with(context)
				.load(uri)
				.into(imageView);
	}

	@Override
	public void loadAnimatedGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
		Glide.with(context)
				.asGif()
				.load(uri)
				.into(imageView);
	}

	@Override
	public boolean supportAnimatedGif() {
		return true;
	}

}
